package com.dbfmp.dynamic.demo.service;

import com.dbfmp.dynamic.demo.common.annotaion.TargetDs;
import com.dbfmp.dynamic.demo.common.enums.DataSourceEnum;
import com.dbfmp.dynamic.demo.entity.User;
import com.dbfmp.dynamic.demo.mapper.UserMapper;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @NAME: UserService
 * @AUTHOR huangtai
 * @DATE: 2019-12-07 20:05
 **/
@Service
public class UserService {

    @Autowired
    public UserMapper userMapper;

    @TargetDs("master")
    public void selectOne() {
        User user = userMapper.selectOne(1);
        System.out.println(user);
    }

    @TargetDs("slave")
    public void selectTwo() {
        User user = userMapper.selectOne(1);
        System.out.println(user);
    }

}
